package cn.xuguowen.user.designPatten.factory.hsp_factory_method;


import cn.xuguowen.user.designPatten.factory.pizza.Pizza;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * ClassName: PizzaStore
 * Package: cn.xuguowen.user.designPatten.factory.tradition
 * Description:
 * 可以订购任意的披萨
 *
 * @Author 徐国文
 * @Create 2023/4/25 14:24
 * @Version 1.0
 */
public abstract class OrderPizza {

    public OrderPizza() {
        Pizza pizza = null;
        String orderType = null;

        do {
            orderType = getPizzaType();
            pizza = getPizza(orderType);
            if (pizza != null) {
                pizza.prepare();
                pizza.bake();
                pizza.cut();
                pizza.box();
            } else {
                System.out.println("无法制作该 " + orderType + " 的披萨");
                break;
            }
        } while (true);
    }

    public abstract Pizza getPizza(String orderType);

    // 获取用户录入的披萨类型
    public String getPizzaType() {
        String pizzaType = "";
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            System.out.print("input pizza 类型：");
            pizzaType = br.readLine();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return pizzaType;
    }
}
